<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title>秒表</title>
	</head>
	<body>
		<input type="button" value="开始" onclick="start()"/>
		<input type="button" value="暂停" onclick="pause()"/>
		<input type="button" value="重置" onclick="rst()"/>
		<span id="f">00</span>:<span id="m">00</span>:<span id="hm">000</span>
		<script type="text/javascript">
			var f=document.getElementById("f");
			var m=document.getElementById("m");
			var hm=document.getElementById("hm");
			var jsq,totalmm=0,hms;
			function start () {
				var initTimer=new Date();
				jsq=setInterval(function () {
					var cur=new Date();
					hms=cur-initTimer+totalmm;					
					var a=hms%1000;
					var b=(hms-a)/1000%60;
					var c=(hms-a-b*1000)/600000;
					hm.innerText=("00"+a).substr(-3,3);
					m.innerText=("0"+b).substr(-2,2);
					f.innerText=("0"+c).substr(-2,2);
				},10)
			}
			function pause () {
				totalmm=hms;
				clearInterval(jsq);
			}
		</script>
	</body>
</html>
